#include "list.h"

/* 链表初始化 */
void list_init(list_t *list)
{
    list->prev = list;
    list->next = list;

    return;
}

void __list_add(list_t * node, list_t * prev, list_t * next)
{
    next->prev = node;
    node->next = next;
    prev->next = node;
    node->prev = prev;

    return;
}

void __list_del(list_t * prev, list_t * next)
{
    next->prev = prev;
    prev->next = next;

    return;
}

void list_add(list_t * node, list_t * head)
{
    __list_add (node, head, head->next);

    return;
}

void list_add_tail(list_t * node, list_t * head)
{
    __list_add (node, head->prev, head);

    return;
}

void list_del(list_t * entry)
{
    __list_del (entry->prev, entry->next);
    list_init (entry);

    return;
}
